#include "mxml.h"



#define XML_GET	1
#define XML_SET	2
#define MENU_COUNT	200
#define LINK_DEPTH	100
#define NUM_LEFT_POS	0

#define HOOKNAMSIZ	100

enum show_type{
	XML_NODE = 1,
	XML_NODE_PARA,
	XML_NODE_OPTION,
};

#define NONE		(-1)	/* for times when NULL won't do */
#define EOS		'\0'	/* C string terminator */

#define ARRAY_SIZE(x)           (sizeof(x)/sizeof(x[0]))
typedef int 		(*FUNCPTR) ();	   /* ptr to function returning int */

struct funcIndex{
	const char *fctag;
	int (*func)();
};

struct paraIndex{
	const char *tag;
	const char *name;
	
	int (*_get)();
	int (*_set)();

	int (*callback)();
};

struct paraOfIndex{
	char * name;
	unsigned int count;
	struct paraIndex *para;

};

struct para_range{
	float max;
	float min;
};

struct menutrInfo{
	u8 type; /*show type*/
	u8 lpos;
	u8 rpos;
	u8 paraLen;
	u16 cursor;
	struct para_range range;

	int usr_data;
	char name[50];
	char paraStr[50];
};

struct menu{
    u16 index;
    u16 edit;
    u16 maxIndex;
    u16 tLen;
    u16 line;
    u16 a_value;
    u16 attr_pos;
    u16 port;
    u8  arrow;
    int  m_tmp;
    //short valPos[2048][2];
    struct menutrInfo menuBuf[MENU_COUNT];
};

struct curop{
	mxml_node_t *curNode;
	mxml_node_t *headNode;
	mxml_node_t *posNode[MENU_COUNT];
	struct {
		mxml_node_t *linkBefore;
		mxml_node_t *linkAfter;
	}link[LINK_DEPTH];
	u8			link_depth;
	u16 depth;
	u8   index_str[100];
	struct menu mnBuf;
};

struct xml_on {
	struct xml_on *next, *prev;
	char name[HOOKNAMSIZ];                    /* interface name        */
	short type;                             /* if type               */
	short flags;                            /* various flags         */

	mxml_node_t *cur;


	int (*onhook)();

	int statistics_valid;

	int keepalive;                          /* keepalive value for SLIP */
	int outfill;                            /* outfill value for SLIP */
};


struct option_pair{
	char *name;
	int val;
};

extern	struct paraIndex* xmlParaSerch(const char *attr,mxml_node_t *cur);
extern	struct menu *xml_key_process(unsigned char key);
extern 	 void Press_LOCK_Key(void);

